import request from '../request.ts'

// 创建用户分组
export const createUserGroup = (data) => {
  return request({
    url: '/user-groups/create',
    method: 'post',
    data
  })
}

// 获取用户分组详情 (POST方式)
export const getUserGroup = (data) => {
  return request({
    url: '/user-groups/get',
    method: 'post',
    data
  })
}

// 获取用户分组详情 (GET方式)
export const getUserGroupById = (groupId) => {
  return request({
    url: `/user-groups/${groupId}`,
    method: 'get'
  })
}

// 更新用户分组 (POST方式)
export const updateUserGroup = (data) => {
  return request({
    url: '/user-groups/update',
    method: 'post',
    data
  })
}

// 更新用户分组 (PUT方式)
export const updateUserGroupById = (groupId, data) => {
  return request({
    url: `/user-groups/${groupId}`,
    method: 'put',
    data
  })
}

// 删除用户分组 (POST方式)
export const deleteUserGroup = (data) => {
  return request({
    url: '/user-groups/delete',
    method: 'post',
    data
  })
}

// 删除用户分组 (DELETE方式)
export const deleteUserGroupById = (groupId) => {
  return request({
    url: `/user-groups/${groupId}`,
    method: 'delete'
  })
}



// 获取我的用户分组 (GET方式)
export const getMyUserGroupsList = () => {
  return request({
    url: '/user-groups/my',
    method: 'get'
  })
}

// 添加用户到分组
export const addUsersToGroup = (data) => {
  return request({
    url: '/user-groups/add-users',
    method: 'post',
    data
  })
}

// 从分组中移除用户
export const removeUsersFromGroup = (data) => {
  return request({
    url: '/user-groups/remove-users',
    method: 'post',
    data
  })
}

// 获取用户组列表（别名）
export const getUserGroups = getMyUserGroupsList
